﻿
<script src="~/Scripts/jquery-easyui-extensions/treegrid/jeasyui.extensions.treegrid.selectCheck.js"></script>
<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="tg1"></table>
</div>


<script>
    $(function () {
        var getFrozenColumns = function () {
            var result = [];

            var c1 = [];
            c1.push({ field: 'ck', checkbox: true });
            c1.push({ field: 'AreaName', title: '地区', width: 150 });
            c1.push({ field: 'ID', title: '主键', width: 100 });
            c1.push({ field: 'Sex1', title: '男', width: 90 });
            c1.push({ field: 'Sex2', title: '女', width: 90 });

            result.push(c1);

            return result;
        };

        var getColumns = function () {
            var result = [];

            var normal = [
                { field: 'TS1', title: '测试1', width: 60 },
                { field: 'TS2', title: '测试2', width: 60 }
            ];
            result.push(normal);

            return result;
        };
        var options = {
            title: "列表【注意 singleSelect 属性的设置】",
            idField: "ID",
            treeField: "AreaName",
            rownumbers: true,
            fit: true,
            border: false,
            singleSelect: false,
            selectOnCheck: false,
            checkOnSelect: false,
            toolbar: [
                {
                    iconCls: 'icon-add',
                    text: "select 宁波节点（含子集）",
                    handler: function () {
                        $("#tg1").treegrid("select", { id: 101, cascade: true });
                    }
                },
                {
                    iconCls: 'icon-add',
                    text: "unselect 宁波节点（含子集）",
                    handler: function () {
                        $("#tg1").treegrid("unselect", { id: 101, cascade: true });
                    }
                },
                "-",
                {
                    iconCls: 'icon-add',
                    text: "check 杭州节点（含子集）",
                    handler: function () {
                        $("#tg1").treegrid("check", { id: 100, cascade: true });
                    }
                },
                {
                    iconCls: 'icon-add',
                    text: "uncheck 杭州节点（含子集）",
                    handler: function () {
                        $("#tg1").treegrid("uncheck", { id: 100, cascade: true });
                    }
                }
            ],
            frozenColumns: getFrozenColumns(),
            columns: getColumns(),
            method: "get",
            url: "/Jsons/treegrid/treegrid-common-data.json"
        };

        $("#tg1").treegrid(options);
    });
</script>